import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.awt.Color;
import javax.swing.border.LineBorder;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.sql.Time;

public class HealthHistoryGUI extends JPanel{
    int location;
    User user = new User();
    
    /**
     * This class creates the Health History Table. If I knew how to just import the database for that user into a panel, I would. 
     * I don't, however, so this has labels that will be updated and pull the correct information out of the Database. There are 
     * buttons to the right of each entry. If clicked, they can pull up the individual treatment record for that day. 
     */
    
    private static final long serialVersionUID = 1L;
    private JTextField textField;
    private JTextField textField_1;
    private JTextField textField_2;
    private JTextField textField_3;
    public HealthHistoryGUI() {
        
        
        
        setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
        
        JPanel panel = new JPanel();
        add(panel);
        panel.setLayout(new BorderLayout(0, 0));
        
        JScrollPane scrollPane = new JScrollPane();
        panel.add(scrollPane);
        
        JLabel lblNewLabel = new JLabel("Patient's Name Health History");
        scrollPane.setColumnHeaderView(lblNewLabel);
        
        JPanel panel_1 = new JPanel();
        panel_1.setBorder(new LineBorder(new Color(0, 0, 0), 2));
        scrollPane.setViewportView(panel_1);
        GridBagLayout gbl_panel_1 = new GridBagLayout();
        gbl_panel_1.columnWidths = new int[]{0, 0, 0, 0, 0, 0, 0, 0};
        gbl_panel_1.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
        gbl_panel_1.columnWeights = new double[]{0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, Double.MIN_VALUE};
        gbl_panel_1.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
        panel_1.setLayout(gbl_panel_1);
        
        JLabel lblDate = new JLabel("Date");
        GridBagConstraints gbc_lblDate = new GridBagConstraints();
        gbc_lblDate.insets = new Insets(0, 0, 5, 5);
        gbc_lblDate.gridx = 1;
        gbc_lblDate.gridy = 0;
        panel_1.add(lblDate, gbc_lblDate);
        
        JLabel lblTime = new JLabel("Time");
        GridBagConstraints gbc_lblTime = new GridBagConstraints();
        gbc_lblTime.insets = new Insets(0, 0, 5, 5);
        gbc_lblTime.gridx = 2;
        gbc_lblTime.gridy = 0;
        panel_1.add(lblTime, gbc_lblTime);
        
        JLabel lblNewLabel_2 = new JLabel("Treating Doctor");
        GridBagConstraints gbc_lblNewLabel_2 = new GridBagConstraints();
        gbc_lblNewLabel_2.insets = new Insets(0, 0, 5, 5);
        gbc_lblNewLabel_2.gridx = 3;
        gbc_lblNewLabel_2.gridy = 0;
        panel_1.add(lblNewLabel_2, gbc_lblNewLabel_2);
        
        JLabel lblAttendingNurse = new JLabel("Attending Nurse");
        GridBagConstraints gbc_lblAttendingNurse = new GridBagConstraints();
        gbc_lblAttendingNurse.insets = new Insets(0, 0, 5, 5);
        gbc_lblAttendingNurse.gridx = 4;
        gbc_lblAttendingNurse.gridy = 0;
        panel_1.add(lblAttendingNurse, gbc_lblAttendingNurse);
        
        JLabel lblSymptoms = new JLabel("Symptoms");
        GridBagConstraints gbc_lblSymptoms = new GridBagConstraints();
        gbc_lblSymptoms.insets = new Insets(0, 0, 5, 5);
        gbc_lblSymptoms.gridx = 5;
        gbc_lblSymptoms.gridy = 0;
        panel_1.add(lblSymptoms, gbc_lblSymptoms);
        
        JLabel lblDiagnosis = new JLabel("Diagnosis");
        GridBagConstraints gbc_lblDiagnosis = new GridBagConstraints();
        gbc_lblDiagnosis.insets = new Insets(0, 0, 5, 5);
        gbc_lblDiagnosis.gridx = 7;
        gbc_lblDiagnosis.gridy = 0;
        panel_1.add(lblDiagnosis, gbc_lblDiagnosis);
        
        JLabel lblDoctorsOrders = new JLabel("Doctors Orders");
        GridBagConstraints gbc_lblDoctorsOrders = new GridBagConstraints();
        gbc_lblDoctorsOrders.insets = new Insets(0, 0, 5, 0);
        gbc_lblDoctorsOrders.gridx = 8;
        gbc_lblDoctorsOrders.gridy = 0;
        panel_1.add(lblDoctorsOrders, gbc_lblDoctorsOrders);
        
        GridBagConstraints gbc_lblNewLabel_6 = new GridBagConstraints();
        gbc_lblNewLabel_6.insets = new Insets(0, 0, 5, 5);
        gbc_lblNewLabel_6.gridx = 5;
        gbc_lblNewLabel_6.gridy = 1;
        
        textField = new JTextField();
        textField.setColumns(10);
        GridBagConstraints gbc_textField = new GridBagConstraints();
        gbc_textField.insets = new Insets(0, 0, 5, 5);
        gbc_textField.fill = GridBagConstraints.HORIZONTAL;
        gbc_textField.gridx = 2;
        gbc_textField.gridy = 2;
        panel_1.add(textField, gbc_textField);
        
        textField_1 = new JTextField();
        textField_1.setColumns(10);
        GridBagConstraints gbc_textField_1 = new GridBagConstraints();
        gbc_textField_1.insets = new Insets(0, 0, 5, 5);
        gbc_textField_1.fill = GridBagConstraints.HORIZONTAL;
        gbc_textField_1.gridx = 3;
        gbc_textField_1.gridy = 2;
        panel_1.add(textField_1, gbc_textField_1);
        
        textField_2 = new JTextField();
        textField_2.setColumns(10);
        GridBagConstraints gbc_textField_2 = new GridBagConstraints();
        gbc_textField_2.insets = new Insets(0, 0, 5, 5);
        gbc_textField_2.fill = GridBagConstraints.HORIZONTAL;
        gbc_textField_2.gridx = 4;
        gbc_textField_2.gridy = 2;
        panel_1.add(textField_2, gbc_textField_2);
        
        textField_3 = new JTextField();
        textField_3.setColumns(10);
        GridBagConstraints gbc_textField_3 = new GridBagConstraints();
        gbc_textField_3.insets = new Insets(0, 0, 5, 5);
        gbc_textField_3.fill = GridBagConstraints.HORIZONTAL;
        gbc_textField_3.gridx = 5;
        gbc_textField_3.gridy = 2;
        panel_1.add(textField_3, gbc_textField_3);
        
        JLabel lblNewLabel_7 = new JLabel("New label");
        GridBagConstraints gbc_lblNewLabel_7 = new GridBagConstraints();
        gbc_lblNewLabel_7.insets = new Insets(0, 0, 5, 5);
        gbc_lblNewLabel_7.gridx = 7;
        gbc_lblNewLabel_7.gridy = 2;
        panel_1.add(lblNewLabel_7, gbc_lblNewLabel_7);
        
        JButton button = new JButton("1.");
        GridBagConstraints gbc_button = new GridBagConstraints();
        gbc_button.insets = new Insets(0, 0, 5, 5);
        gbc_button.gridx = 0;
        gbc_button.gridy = 2;
        panel_1.add(button, gbc_button);
        
        JButton btnDoctorsOrders = new JButton("Doctors Orders");
        GridBagConstraints gbc_btnDoctorsOrders = new GridBagConstraints();
        gbc_btnDoctorsOrders.insets = new Insets(0, 0, 5, 0);
        gbc_btnDoctorsOrders.gridx = 8;
        gbc_btnDoctorsOrders.gridy = 2;
        panel_1.add(btnDoctorsOrders, gbc_btnDoctorsOrders);
        btnDoctorsOrders.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                location = 20;
            }
        });
        
        JPanel panel_2 = new JPanel();
        panel.add(panel_2, BorderLayout.SOUTH);
        
        JButton btnPatientInformation = new JButton("Back");
        btnPatientInformation.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                location = -1;
                
                
            }
        });
        
        JButton btnFillInChart = new JButton("Fill in chart");
        btnFillInChart.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                location = 2;
                textField.setText(((user.getNewestTreatment().getTime().toString())));
                textField_1.setText(user.getNewestTreatment().getTreatingDoctor());
                textField_2.setText(user.getNewestTreatment().getAttendingNurse());
                textField_3.setText(user.getNewestTreatment().getSymptoms());
            }
        });
        panel_2.add(btnFillInChart);
        panel_2.add(btnPatientInformation);
        
        
        
    }
    public int getLoc()
    {
        return location;
    }
    public void setLoc(int i)
    {
        location = i;
    }
    public void act(){
        
    }
    
    public void setUser(User input){
        user = input;
    }
    

}
